﻿using System.Windows;
using Gavel.Common.Component.Extension;

namespace Gavel.Common.Component.Model;

/// <summary>
/// 表格列
/// </summary>
public class TableColumn : DependencyObject
{
    /// <summary>
    /// 列头
    /// </summary>
    public static readonly DependencyProperty HeaderProperty = nameof(HeaderProperty).Register<TableColumn, string>();

    /// <summary>
    /// 列头
    /// </summary>
    public string Header
    {
        get => (string)GetValue(HeaderProperty);
        set => SetValue(HeaderProperty, value);
    }

    /// <summary>
    /// 列宽
    /// </summary>
    public static readonly DependencyProperty WidthProperty = nameof(WidthProperty).Register<TableColumn, GridLength>(new GridLength(1, GridUnitType.Star));

    /// <summary>
    /// 列宽
    /// </summary>
    public GridLength Width
    {
        get => (GridLength)GetValue(WidthProperty);
        set => SetValue(WidthProperty, value);
    }

    /// <summary>
    /// 最小列宽
    /// </summary>
    public static readonly DependencyProperty MinWidthProperty = nameof(MinWidthProperty).Register<TableColumn, double>();

    /// <summary>
    /// 最小列宽
    /// </summary>
    public double MinWidth
    {
        get => (double)GetValue(MinWidthProperty);
        set => SetValue(MinWidthProperty, value);
    }

    /// <summary>
    /// 单元格
    /// </summary>
    public static readonly DependencyProperty CellTemplateProperty = nameof(CellTemplateProperty).Register<TableColumn, DataTemplate>();

    /// <summary>
    /// 单元格
    /// </summary>
    public DataTemplate CellTemplate
    {
        get => (DataTemplate)GetValue(CellTemplateProperty);
        set => SetValue(CellTemplateProperty, value);
    }
}